package com.thfw.test.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.PowerManager;

/**
 * Created by scooper_lxx on 2016/5/23.
 */
public class PowerManagerUtil {

    private PowerManager powerManager;
    private PowerManager.WakeLock wakeLock;
    @SuppressLint("InvalidWakeLockTag")
    public void brightView(Context context){
        powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.ON_AFTER_RELEASE | PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
        wakeLock.acquire();
    }

    public void boardView(){
        if(wakeLock!=null &&  wakeLock.isHeld()){
            wakeLock.release();
        }
    }
}
